<template>
	<div class="main">
		<div class="meedu-filter-box">
			<div class="category2-box">
				<div class="box">
					<div class="label">分类</div>
					<div class="item-box">
						<div class="item" @click="changPaperKnowledge(0,1)" :class="{active:Isactive==0}">
							全部
						</div>
						<div class="item" v-for="(Item, index) in PaperKnowledgeList" :key="index" @click="changPaperKnowledge(Item.value,1)"
						 :class="{active:Isactive==Item.value}">
							{{ Item.label }}
						</div>
					</div>
				</div>
			</div>
		</div>
		<div>
			<div class="paper-item">
				<div class="paper-item-comp" @click="changeRouter(Item.id)" v-for="(Item, index) in KnowledgePaperList" :key="index">
					<div class="title">{{ Item.name }}</div>

					<div class="info">
						<span>总分{{ Item.testPaperScore }}分</span>
						<el-divider direction="vertical"></el-divider>
						<span>总题数{{ Item.questionNum }}</span>
					</div>
				</div>
			</div>
			<el-pagination background layout="prev, pager, next" :total="1000" :current-page="currentPage" @current-change="currentChange"
			 style="margin-top: 1.25rem;">
			</el-pagination>
		</div>
	</div>
</template>

<script>
	import {
		TestManager
	} from "../../../request/test.js";
	export default {
		data() {
			return {
				id: this.$route.query.id,
				PaperKnowledgeList: [],
				KnowledgePaperList: [],
				Isactive: 0,
				currentPage: 1,
			};
		},
		methods: {
			ExamStatistics() {
				this.$router.push("/ExamStatistics");
			},
			changeRouter(val) {
				if (this.id == 1) {
					this.$router.push({
						path: "/Mytest",
						query: {
							Testid: val
						}
					});
				} else
				if (this.id == 3) {

					this.$router.push({
						path: "/exerciseTest",
						query: {
							Testid: val
						}
					});
				}

			},
			//获取知识点列表
			getSystemPaperKnowledge() {
				TestManager.getSystemPaperKnowledge().then((e) => {
					console.log(e);
					this.PaperKnowledgeList = e.data.data;
				});
			},
			changPaperKnowledge(id, val) {
				if (val == 1) {
					this.currentPage = 1;
				}
				if (id == 0) {
					var p = {
						currentPage: this.currentPage,
						pageSize: 5,
					};
				} else {
					var p = {
						currentPage: this.currentPage,
						pageSize: 5,
						rootKnowledgeId: id
					};
				}

				this.Isactive = id;
				TestManager.getSystemPaper(this.qs.stringify(p)).then((e) => {
					console.log(e);

					this.KnowledgePaperList = e.data.data.dataList;
				});
			},
			currentChange(id) {
				this.currentPage = id;
				this.changPaperKnowledge(this.Isactive);
			}
		},
		created() {
			this.getSystemPaperKnowledge();
			this.changPaperKnowledge(0, 0);
		},
	};
</script>

<style scoped="scoped" lang="scss">
	.main {
		width: 90%;
		height: 100px;
		margin-left: 5%;
		margin-right: 5%;
		// background-color: #00B6B4;
	}

	.meedu-filter-box {
		width: 100%;
		margin-top: 1.875rem;
	}

	.meedu-filter-box .category2-box {
		width: 100%;
		height: auto;
		background: -webkit-linear-gradient(left, #03d3bd, #00dbcf);
		border-radius: 8px;
		margin: 0 auto;
		padding: 15px 30px 5px 30px;
		box-sizing: border-box;
	}

	.meedu-filter-box .category2-box .box {
		width: 100%;
		height: auto;
		display: flex;

		flex-direction: row;
	}

	.meedu-filter-box .category2-box .box .label {
		width: 42px;
		height: 14px;
		font-size: 14px;
		font-weight: 400;
		color: white;
		line-height: 14px;
		margin-right: 30px;
		margin-top: 10px;
	}

	.meedu-filter-box .category2-box .box .item-box {
		width: 1068px;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		flex-direction: row;
	}

	.meedu-filter-box .category2-box .box .item-box .item {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 20px;
		font-size: 14px;
		font-weight: 400;
		color: white;
		line-height: 14px;
		padding: 10px 15px;
		cursor: pointer;
		margin-bottom: 10px;
	}

	.paper-item {
		width: 100%;
		display: flex;
		flex-direction: column;
		padding-top: 30px;
		box-sizing: border-box;
	}

	.paper-item-comp {
		width: 100%;
		height: 116px;
		background: #fff;
		border-radius: 8px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		cursor: pointer;
		position: relative;
		box-sizing: border-box;
		padding-left: 30px;
		padding-right: 50px;
		margin-bottom: 30px;
	}

	.paper-item-comp:hover {
		box-shadow: 0 2px 3px -1px #ececec;
	}

	.title {
		height: 16px;
		font-size: 16px;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #333;
		line-height: 16px;
	}

	.info {
		height: 30px;
		font-size: 16px;
		font-family: PingFangSC-Regular, PingFang SC;
		// font-weight: 600;
		// color: #000000;
		color: #666;
		line-height: 30px;
	}

	.active {
		background-color: rgba(160, 175, 187, 0.9);
		border-radius: 4px;
		color: #ffffff;
	}
</style>
